using System;
using System.Windows.Controls;

namespace BattleShipPro
{
    public class BattleShip
    {
        public string Name { get; set; }
        public int Spaces { get; set; }
        public int StartX { get; set; }
        public int StartY { get; set; }
        public Orientation Orientation { get; set; }
        private int _lifeCount;
        public BattleShip(string name, int spaces)
        {
            Name = name;
            Spaces = spaces;
            _lifeCount = Spaces;
        }

        public bool IsAlive()
        {
            return _lifeCount > 0;
        }

        public bool IsInPosition(int x, int y)
        {
            switch (Orientation)
            {
                case Orientation.Horizontal:
                    if (_lifeCount > 0)
                    {
                        bool isInPosition = (x >= StartX && x < StartX + Spaces && y == StartY);
                        if (isInPosition)
                        {
                            _lifeCount--;
                        }
                        return isInPosition;
                    }
                    break;
                case Orientation.Vertical:
                    if (_lifeCount > 0)
                    {
                        bool inPosition = (y >= StartY && y < StartY + Spaces && x == StartX);
                        if (inPosition)
                        {
                            _lifeCount--;
                        }
                        return inPosition;
                    }
                    break;
                default:
                    throw new ArgumentOutOfRangeException();
            }
            return false;
        }
    }
}